﻿@{
	ViewBag.Title = Resources.SysStatistics + ConstValues.strDash + Resources.HuiTongCIS;
}
<div class="easyui-tabs" id="tt">
	<div title="@Resources.AttendencePerson">
		<div id="menuBar" style="height:35px;">
			<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
				@Resources.UserName：<input id="txtUserName" class="easyui-textbox" style="height:27px; width:200px;" />&nbsp;&nbsp;
				<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="searchData(1);">@Resources.Search</a>&nbsp;&nbsp;
			</div>
			<div class="clear"></div>
		</div>
		<div id="dataGrid1"></div>
	</div>
	<div title="@Resources.Industry">
		<div id="menuBar" style="height:35px;">
			<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
				@Resources.Career：<input id="ddlCareer" class="easyui-combobox" style="height:27px; width:200px;" />&nbsp;&nbsp;
				<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="searchData(2);">@Resources.Search</a>&nbsp;&nbsp;
			</div>
			<div class="clear"></div>
		</div>
		<div id="dataGrid2"></div>
	</div>
	<div title="@Resources.AttendenceIdentity">
		<div id="menuBar" style="height:35px;">
			<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
				@Resources.AttendenceIdentity：<input id="ddlAttendenceIdentity" class="easyui-combobox" style="height:27px; width:200px;" />&nbsp;&nbsp;
				<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="searchData(3);">@Resources.Search</a>&nbsp;&nbsp;
			</div>
			<div class="clear"></div>
		</div>
		<div id="dataGrid3"></div>
	</div>
</div>

@section Scripts {
<script>
	common.setCurrentMenu("SysStatistics");

	$(function () {
		$("#tt").tabs({
			width: $(window).width() - 265,
		});

		var orgCount = 0;
		$("#ddlCareer").combobox({
			url: "@Url.Action(nameof(UtilityController.GetCareerWithAll), nameof(UtilityController).GetControllerName())",
			panelWidth: 400,
			valueField: "id",
			textField: "name",
			editable: false,
			onLoadSuccess: function(data) {
				orgCount = data.length;
				$(this).combobox("setValue", "@Resources.All");
			},
			onShowPanel: function () {
				if (orgCount < 10) {
					$(this).combobox("panel").height("auto");
				} else {
					$(this).combobox("panel").height(200);
				}
			}
		});
			
		var orgCount_2 = 0;			
		$("#ddlAttendenceIdentity").combobox({
			url: "@Url.Action(nameof(UtilityController.GetAllAttendenceIdentityTypeWithAll), nameof(UtilityController).GetControllerName())",
			editable: false,
			valueField: "name",
			textField: "name",
			onLoadSuccess: function(data) {
				orgCount_2 = data.length;
				$(this).combobox("setValue", "@Resources.All");
			},
			onShowPanel: function () {
				if (orgCount_2 < 10) {
					$(this).combobox("panel").height("auto");
				} else {
					$(this).combobox("panel").height(200);
				}
			}
		});

		$("#txtUserName").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData(1);
			}
		});
		$("#ddlCareer").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData(2);
			}
		});
		$("#ddlAttendenceIdentity").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData(3);
			}
		});

		$("#dataGrid1").datagrid({
			url: "@Url.Action(nameof(SysStatisticsController.GetAttendencePerson),
					nameof(SysStatisticsController).GetControllerName())",
			method: "get",
			singleSelect: true,
			fitColumns: true,
			width: $(window).width() - 285,
			height: $(window).height() - 158,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100, 
			pageList: [100, 200, 300, 400, 500],
			columns: [[
				{ field: "userName", title: "@Resources.UserName", align: "center", sortable: true, width: 100 },
				{ field: "attendenceCount", title: "@Resources.AttendenceCount", align: "center", sortable: true, width: 100 },
				{ field: "contributeCount", title: "@Resources.ContributeCount", align: "center", sortable: true, width: 100 },
				{ field: "alipayCount", title: "@Resources.AliPay", align: "center", sortable: true, width: 100 } ,
				{ field: "epayCount", title: "@Resources.Epay", align: "center", sortable: true, width: 100 },
				{ field: "cashCount", title: "@Resources.Cash", align: "center", sortable: true, width: 100 } ,
				{ field: "transferCount", title: "@Resources.Transfer", align: "center", sortable: true, width: 100 }
			]],
			onBeforeLoad: function(param) {
				param.random = Math.random();
			}
		});

		$("#dataGrid2").datagrid({
			url: "@Url.Action(nameof(SysStatisticsController.GetAttendenceCareer),
					nameof(SysStatisticsController).GetControllerName())",
			method: "get",
			singleSelect: true,
			fitColumns: true,
			width: $(window).width() - 285,
			height: $(window).height() - 158,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100, 
			pageList: [100, 200, 300, 400, 500],
			columns: [[
				{ field: "careerName", title: "@Resources.Career", align: "center", sortable: true, width: 100 },
				{ field: "attendenceCount", title: "@Resources.AttendenceCount", align: "center", sortable: true, width: 100 }
			]],
			onBeforeLoad: function(param) {
				param.random = Math.random();
			},
		});

		$("#dataGrid3").datagrid({
			url: "@Url.Action(nameof(SysStatisticsController.GetAttendenceIdentity),
					nameof(SysStatisticsController).GetControllerName())",
			method: "get",
			singleSelect: true,
			fitColumns: true,
			width: $(window).width() - 285,
			height: $(window).height() - 158,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100, 
			pageList: [100, 200, 300, 400, 500],
			columns: [[
				{ field: "identityName", title: "@Resources.AttendenceIdentity", align: "center", sortable: true, width: 100 },
				{ field: "attendenceCount", title: "@Resources.AttendenceCount", align: "center", sortable: true, width: 100 }
			]],
			onBeforeLoad: function(param) {
				param.random = Math.random();
			},
		});

		$(window).resize(function () {
			$("#tt").tabs({
				width: $(window).width() - 270,
			});
			$("#dataGrid1").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 158
			});
			$("#dataGrid2").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 158
			});
			$("#dataGrid3").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 158
			});
		});
	});

	function searchData(type) {
		if (type == 1) {
			$("#dataGrid1").datagrid("load", {
				UserName: $("#txtUserName").textbox("getValue")
			});
		}
		else if (type == 2) {
			$("#dataGrid2").datagrid("load", {
				CareerId: $("#ddlCareer").combobox("getValue")
			});
		}
		else if (type == 3) {
			$("#dataGrid3").datagrid("load", {
				AttendenceIdentity: $("#ddlAttendenceIdentity").combobox("getText")
			});
		}
	}
</script>
}